#!/user/bin/env node

const fs = require('fs'),
      file = process.argv[2];

//fs.readFile('./' + file,function(err,buf){
 // if(err){
   // console.log(err);
   // process.exit(3);
// }

  if(process.argv.length !== 3){
    console.log("命令行参数的格式：cmd file_name" );
    console.log(1);
    process.exit(1);
  }

let buf;
try{
  console.log(2);
  buf = fs.readFileSync(file);
}catch(e){
  console.error(e.message);
  process.exit(2);
}
if(buf.toString('ascii', 0,2) === "BM"){
    console.log('width:', buf.readInt32LE(0x12));
    console.log("height:", buf.readInt32LE(0x16));
    console.log('color depth:', buf.readUInt16LE(0x1c));
}else{
  console.log('err');
  console.log(buf);
}



